package base.day26.udp;

import java.io.IOException;
import java.net.*;

public class SendDemo4 {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();

        String s="广播";
        byte[] bytes = s.getBytes();
        int port=10004;
        //要发送的广播地址
        InetAddress address = InetAddress.getByName("255.255.255.255");

        //将数据添加进包中
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);

        ds.send(dp);
        ds.close();
    }
}
